#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
#include <stdlib.h>
#include <assert.h>

/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
int* twoSum(int* nums, int numsSize, int target, int* returnSize)
{
    assert(nums);
    for (int i = 0; i < numsSize; i++)
    {
        for (int j = i + 1; j < numsSize; j++)
        {
            if (nums[i] + nums[j] == target)
            {
                int* ret = (int*)malloc(2 * sizeof(int));
                ret[0] = i;
                ret[1] = j;
                *returnSize = 2;
                return ret;
            }
        }
    }
    returnSize = 0;
    return NULL;
}

int main()
{
    int arr[] = { 2,7,11,15 };
    int target = 9;
    int sz = sizeof(arr) / sizeof(arr[0]);
    int* returnSize = NULL;
    int* ret = twoSum(arr, sz, target, returnSize);
    for (int i = 0; i < 2; i++)
    {
        printf("%d ", ret[i]);
    }
    return 0;
}